home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / osi / x500 / quipu-patches / kerberos / kerberos.patch < prev    next >
Encoding:
Text File  |  1993-04-27  |  25.5 KB  |  935 lines

  1. *** dsap/common/attribute.c.orig    Mon Sep 21 17:11:32 1992
  2. --- dsap/common/attribute.c    Fri Sep 25 10:08:42 1992
  3. ***************
  4. *** 53,58 ****
  5. --- 53,61 ----
  6.   AttributeType at_searchacl;
  7.   AttributeType at_listacl;
  8.   AttributeType at_authpolicy;
  9. + #ifdef KERBEROS
  10. + AttributeType at_kerberosname;
  11. + #endif
  12.   OID alias_oc;
  13.   OID quipu_dsa_oid;
  14.   OID extern_obj_oid;
  15. ***************
  16. *** 90,95 ****
  17. --- 93,101 ----
  18.       at_searchacl    = AttrT_new (SEARCHACL_OID);
  19.       at_listacl      = AttrT_new (LISTACL_OID);
  20.       at_authpolicy   = AttrT_new (AUTHPOLICY_OID);
  21. + #ifdef KERBEROS
  22. +     at_kerberosname = AttrT_new (KERBEROSNAME_OID);
  23. + #endif
  24.   
  25.       at_subord     = AttrT_new (SUBORD_OID);
  26.       at_xref     = AttrT_new (XREF_OID);
  27. *** h/quipu/bind.h.orig    Tue Jun 23 17:13:11 1992
  28. --- h/quipu/bind.h    Fri Sep 25 16:21:15 1992
  29. ***************
  30. *** 25,30 ****
  31. --- 25,33 ----
  32.   #define QUIPUBIND
  33.   #include "quipu/name.h"
  34.   #include "quipu/authen.h"
  35. + #ifdef KERBEROS
  36. + #include <krb.h>
  37. + #endif
  38.   
  39.       /* THIS SECTION GIVES BIND PARAMETERS */
  40.   
  41. ***************
  42. *** 52,57 ****
  43. --- 55,61 ----
  44.       char * dba_vtmp;    /* pepsy */
  45.       int    dba_vlen;    /* pepsy */
  46.       struct alg_id dba_alg;
  47. +     struct type_UNIV_EXTERNAL *dba_external;
  48.   };
  49.   
  50.   struct ds_bind_error {
  51. ***************
  52. *** 70,74 ****
  53. --- 74,95 ----
  54.       char    dbe_data[DBE_SIZE];        /*   data */
  55.       
  56.   };
  57. + #ifdef KERBEROS
  58. + struct kerberos_parms {
  59. +     DN    kp_dn;        /* DN to bind as */
  60. +     int    kp_version;
  61. + #define AUTH_TYPE_KERBEROS_V4    1
  62. + #define AUTH_TYPE_KERBEROS_V5    2
  63. +     u_long    kp_enonce[2];
  64. + #define kp_nonce    kp_enonce[0]
  65. +     KTEXT_ST kp_ktxt;    /* kerberos authenticator and ticket */
  66. + };
  67. + #endif /* KERBEROS */
  68.   
  69.   #endif
  70. *** h/quipu/oid.h.orig    Sat Jun 27 10:39:02 1992
  71. --- h/quipu/oid.h    Fri Sep 25 10:08:43 1992
  72. ***************
  73. *** 65,70 ****
  74. --- 65,71 ----
  75.   #define SEARCHACL_OID    "0.9.2342.19200300.100.1.57"
  76.   #define LISTACL_OID    "0.9.2342.19200300.100.1.58"
  77.   #define AUTHPOLICY_OID    "0.9.2342.19200300.100.1.59"
  78. + #define KERBEROSNAME_OID    "1.3.6.1.4.1.250.1.33"
  79.   
  80.       /* Signature Algorithm */
  81.   #ifdef  OSISEC
  82. *** quipu/sys_tai.c.orig    Sat Aug 29 09:57:38 1992
  83. --- quipu/sys_tai.c    Fri Sep 25 10:08:45 1992
  84. ***************
  85. *** 61,66 ****
  86. --- 61,70 ----
  87.   #ifdef TURBO_INDEX
  88.   extern int optimized_only;
  89.   #endif
  90. + #ifdef KERBEROS
  91. + extern char *kerberos_name;
  92. + extern char *kerberos_keyfile;
  93. + #endif
  94.   
  95.   unsigned bind_policy = POLICY_ACCESS_ALL;
  96.   unsigned strong_policy = POLICY_ACCESS_ALL;
  97. ***************
  98. *** 109,114 ****
  99. --- 113,120 ----
  100.   #define GETEDB_SIZE     48
  101.   #define AUTHFILE     50
  102.   #define FASTSTART     51
  103. + #define KERBEROS_NAME     52
  104. + #define KERBEROS_KEY     53
  105.   
  106.   static  CMD_TABLE  cmdtab[] =
  107.   {
  108. ***************
  109. *** 156,161 ****
  110. --- 162,171 ----
  111.       "INDEX_SUBTREE",    INDEX_SUBTREE,
  112.       "INDEX_SIBLINGS",    INDEX_SIBLINGS,
  113.   #endif
  114. + #ifdef KERBEROS
  115. +     "KERBEROS_NAME",    KERBEROS_NAME,
  116. +     "KERBEROS_KEY",        KERBEROS_KEY,
  117. + #endif
  118.   #ifndef NO_STATS
  119.       "STATS",    STATS,
  120.   #endif
  121. ***************
  122. *** 395,400 ****
  123. --- 405,420 ----
  124.           index_siblings(arg);
  125.                   DLOG(log_dsap, LLOG_TRACE, ("Tailor index siblings %s", arg));
  126.                   break;
  127. + #endif
  128. + #ifdef KERBEROS
  129. +     case KERBEROS_NAME:
  130. +         kerberos_name = strdup( arg );
  131. +                 DLOG(log_dsap, LLOG_TRACE, ("Tailor kerberos name %s", arg));
  132. +         break;
  133. +     case KERBEROS_KEY:
  134. +         kerberos_keyfile = strdup( arg );
  135. +                 DLOG(log_dsap, LLOG_TRACE, ("Tailor kerberos keyfile %s", arg));
  136. +         break;
  137.   #endif
  138.           default:
  139.           return NOTOK;
  140. *** quipu/conn_init.c.bak    Fri Sep 25 17:18:32 1992
  141. --- quipu/conn_init.c    Fri Sep 25 17:19:08 1992
  142. ***************
  143. *** 177,182 ****
  144. --- 177,185 ----
  145.       switch(ds_bind_return)
  146.       {
  147.       case DS_OK:
  148. + #ifdef KERBEROS
  149. +     cn->cn_dn = dn_cpy(ds->ds_bind_arg.dba_dn);
  150. + #endif
  151.       conn_init_res(cn);
  152.       break;
  153.       case DS_ERROR_CONNECT:
  154. *** quipu/ds_add.c.bak    Fri Sep 25 16:30:12 1992
  155. --- quipu/ds_add.c    Fri Sep 25 16:30:57 1992
  156. ***************
  157. *** 67,72 ****
  158. --- 67,73 ----
  159.   int authp;
  160.   extern int read_only;
  161.   extern int    entry_cmp();
  162. + extern DN trust_dn();
  163.   
  164.       DLOG (log_dsap,LLOG_TRACE,("ds_add"));
  165.   
  166. ***************
  167. *** 187,193 ****
  168.       else
  169.           authp = AP_SIMPLE;
  170.   
  171. !     if (check_acl ((authtype % 3) >= authp ? binddn : NULLDN, ACL_ADD,
  172.           entryptr->e_acl->ac_child,dntop) == NOTOK) {
  173.           error->dse_type = DSE_SECURITYERROR;
  174.           error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
  175. --- 188,194 ----
  176.       else
  177.           authp = AP_SIMPLE;
  178.   
  179. !     if (check_acl ( trust_dn( binddn, authtype, authp ), ACL_ADD,
  180.           entryptr->e_acl->ac_child,dntop) == NOTOK) {
  181.           error->dse_type = DSE_SECURITYERROR;
  182.           error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
  183. *** quipu/ds_compare.c.bak    Fri Sep 25 16:38:20 1992
  184. --- quipu/ds_compare.c    Fri Sep 25 16:39:01 1992
  185. ***************
  186. *** 56,61 ****
  187. --- 56,62 ----
  188.   int retval;
  189.   DN realtarget;
  190.   int authp;
  191. + extern DN trust_dn();
  192.   
  193.       DLOG (log_dsap,LLOG_TRACE,("ds_compare"));
  194.   
  195. ***************
  196. *** 110,116 ****
  197.       authp = entryptr->e_authp ? entryptr->e_authp->ap_readandcompare :
  198.           AP_SIMPLE;
  199.   
  200. !     if (check_acl ((authtype % 3) >= authp ? binddn : NULLDN, ACL_COMPARE,
  201.           entryptr->e_acl->ac_entry, realtarget) == NOTOK) {
  202.           if (dsp && (check_acl (binddn,ACL_COMPARE,entryptr->e_acl->ac_entry, realtarget) == OK)) {
  203.               error->dse_type = DSE_SECURITYERROR;
  204. --- 111,117 ----
  205.       authp = entryptr->e_authp ? entryptr->e_authp->ap_readandcompare :
  206.           AP_SIMPLE;
  207.   
  208. !     if (check_acl ( trust_dn( binddn, authtype, authp ), ACL_COMPARE,
  209.           entryptr->e_acl->ac_entry, realtarget) == NOTOK) {
  210.           if (dsp && (check_acl (binddn,ACL_COMPARE,entryptr->e_acl->ac_entry, realtarget) == OK)) {
  211.               error->dse_type = DSE_SECURITYERROR;
  212. *** quipu/ds_list.c.bak    Fri Sep 25 16:33:11 1992
  213. --- quipu/ds_list.c    Fri Sep 25 16:37:18 1992
  214. ***************
  215. *** 35,40 ****
  216. --- 35,41 ----
  217.   extern LLog * log_dsap;
  218.   extern Entry database_root;
  219.   static int build_result();
  220. + extern DN trust_dn();
  221.   
  222.   do_ds_list (arg, error, result, binddn, target, di_p, dsp, authtype)
  223.       register struct ds_list_arg          *arg;
  224. ***************
  225. *** 118,124 ****
  226.       /* check parent will allow listing */
  227.       sizelimit = SVC_NOSIZELIMIT;
  228.       if ( entryptr->e_lacl != NULLAV ) {
  229. !         if ( check_lacl( (authtype % 3) >= authp ? binddn : NULLDN,
  230.               realtarget, entryptr->e_lacl, SACL_SINGLELEVEL,
  231.               &sizelimit ) == NOTOK ) {
  232.               /* security error */
  233. --- 119,125 ----
  234.       /* check parent will allow listing */
  235.       sizelimit = SVC_NOSIZELIMIT;
  236.       if ( entryptr->e_lacl != NULLAV ) {
  237. !         if ( check_lacl( trust_dn( binddn, authtype, authp ),
  238.               realtarget, entryptr->e_lacl, SACL_SINGLELEVEL,
  239.               &sizelimit ) == NOTOK ) {
  240.               /* security error */
  241. ***************
  242. *** 129,135 ****
  243.               return( DS_ERROR_REMOTE );
  244.           }
  245.       } 
  246. !     if (check_acl ((authtype % 3) >= authp ? binddn : NULLDN,
  247.           ACL_READ, entryptr->e_acl->ac_child, realtarget) != OK) {
  248.           if (dsp && (check_acl (binddn,ACL_READ, entryptr->e_acl->ac_child, realtarget) == OK)) {
  249.               error->dse_type = DSE_SECURITYERROR;
  250. --- 130,136 ----
  251.               return( DS_ERROR_REMOTE );
  252.           }
  253.       } 
  254. !     if (check_acl (trust_dn( binddn, authtype, authp ),
  255.           ACL_READ, entryptr->e_acl->ac_child, realtarget) != OK) {
  256.           if (dsp && (check_acl (binddn,ACL_READ, entryptr->e_acl->ac_child, realtarget) == OK)) {
  257.               error->dse_type = DSE_SECURITYERROR;
  258. ***************
  259. *** 156,163 ****
  260.   
  261.       dn_free (realtarget);
  262.   
  263. !     build_result (arg, entryptr, result, error,
  264. !         (authtype % 3) >= authp ? binddn : NULLDN , dsp, sizelimit);
  265.       return (DS_OK);
  266.   }
  267.   
  268. --- 157,164 ----
  269.   
  270.       dn_free (realtarget);
  271.   
  272. !     build_result (arg, entryptr, result, error, trust_dn( binddn,
  273. !         authtype, authp ), dsp, sizelimit);
  274.       return (DS_OK);
  275.   }
  276.   
  277. *** quipu/ds_modifyrdn.c.bak    Fri Sep 25 16:28:21 1992
  278. --- quipu/ds_modifyrdn.c    Fri Sep 25 16:30:04 1992
  279. ***************
  280. *** 57,62 ****
  281. --- 57,63 ----
  282.   int retval;
  283.   int authp, pauthp;
  284.   extern int read_only;
  285. + DN trust_dn();
  286.   
  287.       DLOG (log_dsap,LLOG_TRACE,("ds_modifyrdn"));
  288.   
  289. ***************
  290. *** 134,143 ****
  291.           pauthp = authp = AP_SIMPLE;
  292.       }
  293.   
  294. !     if ((check_acl ((authtype % 3) >= authp ? binddn : NULLDN, ACL_WRITE,
  295.           entryptr->e_acl->ac_entry, target) == NOTOK)
  296.           || ((entryptr->e_parent->e_data != E_TYPE_CONSTRUCTOR)
  297. !         && (check_acl ((authtype % 3) >= pauthp ? binddn : NULLDN,
  298.           ACL_WRITE,entryptr->e_parent->e_acl->ac_child, target)
  299.           == NOTOK)) ) {
  300.           error->dse_type = DSE_SECURITYERROR;
  301. --- 135,144 ----
  302.           pauthp = authp = AP_SIMPLE;
  303.       }
  304.   
  305. !     if ((check_acl ( trust_dn( binddn, authtype, authp ), ACL_WRITE,
  306.           entryptr->e_acl->ac_entry, target) == NOTOK)
  307.           || ((entryptr->e_parent->e_data != E_TYPE_CONSTRUCTOR)
  308. !         && (check_acl ( trust_dn( binddn, authtype, pauthp ),
  309.           ACL_WRITE,entryptr->e_parent->e_acl->ac_child, target)
  310.           == NOTOK)) ) {
  311.           error->dse_type = DSE_SECURITYERROR;
  312. *** quipu/ds_read.c.bak    Fri Sep 25 16:32:35 1992
  313. --- quipu/ds_read.c    Fri Sep 25 16:35:47 1992
  314. ***************
  315. *** 64,69 ****
  316. --- 64,70 ----
  317.   #endif
  318.   DN realtarget;
  319.   char authp;
  320. + extern DN trust_dn();
  321.   
  322.       DLOG (log_dsap,LLOG_TRACE,("ds_read"));
  323.   
  324. ***************
  325. *** 141,147 ****
  326.   
  327.       /* entry has got a full list of attributes,  eventually
  328.          select one required */
  329. !     if (check_acl ((authtype % 3) >= authp ? binddn : NULLDN, ACL_READ,
  330.           entryptr->e_acl->ac_entry, realtarget) == NOTOK) {
  331.           if (dsp && (check_acl (binddn,ACL_READ,entryptr->e_acl->ac_entry, realtarget) == OK)) {
  332.               error->dse_type = DSE_SECURITYERROR;
  333. --- 142,148 ----
  334.   
  335.       /* entry has got a full list of attributes,  eventually
  336.          select one required */
  337. !     if (check_acl ( trust_dn( binddn, authtype, authp ), ACL_READ,
  338.           entryptr->e_acl->ac_entry, realtarget) == NOTOK) {
  339.           if (dsp && (check_acl (binddn,ACL_READ,entryptr->e_acl->ac_entry, realtarget) == OK)) {
  340.               error->dse_type = DSE_SECURITYERROR;
  341. *** quipu/ds_remove.c.bak    Fri Sep 25 16:31:03 1992
  342. --- quipu/ds_remove.c    Fri Sep 25 16:32:05 1992
  343. ***************
  344. *** 50,55 ****
  345. --- 50,56 ----
  346.   int retval;
  347.   int authp, pauthp;
  348.   extern int read_only;
  349. + extern DN trust_dn();
  350.   
  351.       DLOG (log_dsap,LLOG_TRACE,("ds remove entry"));
  352.   
  353. ***************
  354. *** 128,136 ****
  355.       }
  356.   
  357.       if ( ((entryptr->e_parent->e_data == E_TYPE_CONSTRUCTOR)
  358. !         && (check_acl ((authtype % 3) >= authp ? binddn : NULLDN, ACL_WRITE,
  359.           entryptr->e_acl->ac_entry, target) == NOTOK))
  360. !         || (check_acl ((authtype % 3) >= pauthp ? binddn : NULLDN,
  361.           ACL_WRITE, entryptr->e_parent->e_acl->ac_child, target) == NOTOK)) {
  362.           error->dse_type = DSE_SECURITYERROR;
  363.           error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
  364. --- 129,137 ----
  365.       }
  366.   
  367.       if ( ((entryptr->e_parent->e_data == E_TYPE_CONSTRUCTOR)
  368. !         && (check_acl ( trust_dn( binddn, authtype, authp ), ACL_WRITE,
  369.           entryptr->e_acl->ac_entry, target) == NOTOK))
  370. !         || (check_acl ( trust_dn( binddn, authtype, pauthp ),
  371.           ACL_WRITE, entryptr->e_parent->e_acl->ac_child, target) == NOTOK)) {
  372.           error->dse_type = DSE_SECURITYERROR;
  373.           error->ERR_SECURITY.DSE_sc_problem = DSE_SC_ACCESSRIGHTS;
  374. *** quipu/dish/bind.c.orig    Wed Jun 24 11:07:02 1992
  375. --- quipu/dish/bind.c    Thu Oct  1 13:50:33 1992
  376. ***************
  377. *** 43,48 ****
  378. --- 43,56 ----
  379.   
  380.   #include "osisec-stub.h"
  381.   
  382. + #ifdef KERBEROS
  383. + #define DEFAULT_KERBEROS_SERVICE    "x500dsa"
  384. + static char    *kerberos_service;
  385. + static char    *kerberos_instance;
  386. + static u_long    kerberos_nonce;
  387. + #endif
  388.   extern DN       fixed_pos;
  389.   DN            user_name;
  390.   
  391. ***************
  392. *** 229,234 ****
  393. --- 237,253 ----
  394.               auth_type = DBA_AUTH_SIMPLE;
  395.           else if (test_arg (argv[x], "-strong", 3))
  396.               auth_type = DBA_AUTH_STRONG;
  397. + #ifdef KERBEROS
  398. +         else if (test_arg (argv[x], "-kerberos", 3))
  399. +             auth_type = DBA_AUTH_EXTERNAL;
  400. +         else if (test_arg (argv[x], "-instance", 3)) {
  401. +             if ( ++x == argc || *argv[x] == '-' ) {
  402. +                 Usage( argv[0] );
  403. +                 return( NOTOK );
  404. +             }
  405. +             kerberos_instance = strdup( argv[x] );
  406. +         }
  407. + #endif
  408.           /* -password sets the `key', whatever the mode  */
  409.           else if (test_arg (argv[x], "-password",2)) {
  410.               got_pass = TRUE;
  411. ***************
  412. *** 301,307 ****
  413. --- 320,331 ----
  414.       else
  415.           newdn = NULLDN;
  416.   
  417. + #ifdef KERBEROS
  418. +     if (auth_type != DBA_AUTH_EXTERNAL
  419. +         && ((got_name && ! got_pass) || (*password == 0))) {
  420. + #else
  421.       if ((got_name && ! got_pass) || (*password == 0)) {
  422. + #endif
  423.           bindarg.dba_passwd_len = 0;
  424.           bindarg.dba_passwd[0]  = 0;
  425.           if ((*username != 0) && (auth_type != DBA_AUTH_NONE)) {
  426. ***************
  427. *** 314,320 ****
  428. --- 338,349 ----
  429.           (void) strcpy (bindarg.dba_passwd, password);
  430.       }
  431.   
  432. + #ifdef KERBEROS
  433. +     if ((bindarg.dba_passwd_len == 0) && (auth_type != DBA_AUTH_STRONG)
  434. +         && auth_type != DBA_AUTH_EXTERNAL)
  435. + #else
  436.       if ((bindarg.dba_passwd_len == 0) && (auth_type != DBA_AUTH_STRONG))
  437. + #endif
  438.           auth_type = DBA_AUTH_NONE;
  439.   
  440.       if (*username == 0) {
  441. ***************
  442. *** 348,353 ****
  443. --- 377,387 ----
  444.           if (sign_bindarg() != OK)
  445.               bindarg.dba_auth_type = DBA_AUTH_NONE;
  446.           break;
  447. + #ifdef KERBEROS
  448. +     case DBA_AUTH_EXTERNAL:
  449. +         kerberos_bindarg();
  450. +         break;
  451. + #endif
  452.       }
  453.   
  454.       if (isnumeric (bdsa) && (dsadn = sequence_dn (atoi (bdsa)))) {
  455. ***************
  456. *** 469,475 ****
  457.               dsa_address = myname;
  458.       }
  459.   
  460. !     if (bound) 
  461.           (void) ds_unbind ();
  462.           
  463.       bound = FALSE;
  464. --- 503,509 ----
  465.               dsa_address = myname;
  466.       }
  467.   
  468. !     if (bound)
  469.           (void) ds_unbind ();
  470.           
  471.       bound = FALSE;
  472. ***************
  473. *** 494,499 ****
  474. --- 528,545 ----
  475.           return (NOTOK);
  476.       } 
  477.       (void) signal (SIGALRM, SIG_IGN);
  478. + #ifdef KERBEROS
  479. +     if ( bindarg.dba_auth_type == DBA_AUTH_EXTERNAL ) {
  480. +         if ( kerberos_check_mutual( &bindresult ) == NOTOK ) {
  481. +             ps_print( OPT,
  482. +                 "*** DSA failed mutual authentication ***\n" );
  483. +             (void) ds_unbind();
  484. +             return( NOTOK );
  485. +         }
  486. +     }
  487. + #endif
  488.       main_dsa_id = dsap_ad;
  489.   
  490.   #ifndef NO_STATS
  491. ***************
  492. *** 955,957 ****
  493. --- 1001,1086 ----
  494.   
  495.       return (OK);
  496.   }
  497. + #ifdef KERBEROS
  498. + static kerberos_bindarg()
  499. + {
  500. +     struct type_UNIV_EXTERNAL    *e;
  501. +     struct kerberos_parms        kp;
  502. +     PE                pe;
  503. +     int                err;
  504. +     struct timeval            tv;
  505. +     char                realm[REALM_SZ];
  506. +     extern char            *psap2hostname();
  507. +     e = (struct type_UNIV_EXTERNAL *) calloc( 1,
  508. +         sizeof(struct type_UNIV_EXTERNAL) );
  509. +     e->encoding = (struct choice_UNIV_0 *) calloc( 1,
  510. +         sizeof(struct choice_UNIV_0) );
  511. +     bindarg.dba_external = e;
  512. +     bindarg.dba_auth_type = DBA_AUTH_EXTERNAL;
  513. +     e->indirect__reference = AUTH_TYPE_KERBEROS_V4;
  514. +     e->direct__reference = NULLOID;
  515. +     e->data__value__descriptor = str2qb( "KRBv4 client credentials",
  516. +         24, 1 );
  517. +     kp.kp_dn = bindarg.dba_dn;
  518. +     kp.kp_version = AUTH_TYPE_KERBEROS_V4;
  519. +     if ( kerberos_service == NULL )
  520. +         kerberos_service = DEFAULT_KERBEROS_SERVICE;
  521. +     if ( kerberos_instance == NULL ) {
  522. +         struct PSAPaddr    *pa;
  523. +         char        *p;
  524. +         pa = str2paddr( dsa_address, NULLNA );
  525. +         if ( (p = psap2hostname( pa )) != NULL )
  526. +             kerberos_instance = strdup( p );
  527. +         else
  528. +             kerberos_instance = "";
  529. +     }
  530. +     if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) {
  531. +         ps_printf( OPT, "krb_get_tf_realm failed! (%s)\n",
  532. +             krb_err_txt[err]);
  533. +         return;
  534. +     }
  535. +     gettimeofday( &tv, NULL );
  536. +     kerberos_nonce = tv.tv_usec;
  537. +     if ( (err = krb_mk_req( &(kp.kp_ktxt), kerberos_service,
  538. +         kerberos_instance, realm, kerberos_nonce )) != KSUCCESS ) {
  539. +         ps_printf( OPT, "krb_mk_req failed! (%s)\n", krb_err_txt[err]);
  540. +         return;
  541. +     }
  542. +     if ( encode_kerberos_parms( &pe, &kp ) == NOTOK ) {
  543. +         ps_printf( OPT, "encode_kerberos_parms failed!\n" );
  544. +         return;
  545. +     }
  546. +     e->encoding->offset = choice_UNIV_0_single__ASN1__type;
  547. +     e->encoding->un.single__ASN1__type = pe;
  548. + }
  549. + kerberos_check_mutual( res )
  550. + struct ds_bind_arg    *res;
  551. + {
  552. +     struct type_UNIV_EXTERNAL    *e = res->dba_external;
  553. +     PE                pe;
  554. +     struct kerberos_parms        *kp;
  555. +     if ( e == (struct type_UNIV_EXTERNAL *) 0 )
  556. +         return( NOTOK );
  557. +     pe = e->encoding->un.single__ASN1__type;
  558. +     /* decode the kerberos authentication parameters */
  559. +     if ( decode_kerberos_parms( pe, &kp ) == NOTOK )
  560. +         return( NOTOK );
  561. +     pe_free( pe );
  562. +     return( kp->kp_nonce == (kerberos_nonce + 1) ? OK : NOTOK );
  563. + }
  564. + #endif
  565. *** quipu/ds_modify.c.bak    Thu Oct  1 13:53:32 1992
  566. --- quipu/ds_modify.c    Wed Sep 30 21:46:35 1992
  567. ***************
  568. *** 58,63 ****
  569. --- 58,91 ----
  570.   
  571.   int updateerror;
  572.   
  573. + DN trust_dn( dn, authtype, authpolicy )
  574. +     DN    dn;
  575. +     int    authtype;
  576. +     int    authpolicy;
  577. + {
  578. +     switch ( authpolicy ) {
  579. +     case AP_TRUST:
  580. +         return( dn );
  581. +         break;
  582. +     case AP_SIMPLE:
  583. +         return( authtype >= DBA_AUTH_SIMPLE ? dn : NULLDN );
  584. +         break;
  585. +     case AP_STRONG:
  586. +         return( authtype == DBA_AUTH_STRONG ||
  587. +             authtype == DBA_AUTH_EXTERNAL ? dn : NULLDN );
  588. +         break;
  589. +     default:
  590. +         LLOG( log_dsap, LLOG_EXCEPTIONS, ("unknown authpolicy %d",
  591. +             authpolicy) );
  592. +         break;
  593. +     }
  594. +     return( NULLDN );
  595. + }
  596.   do_ds_modifyentry (arg, error, binddn, target, di_p, dsp, authtype)
  597.       struct ds_modifyentry_arg   *arg;
  598.       struct DSError              *error;
  599. ***************
  600. *** 178,184 ****
  601.       authp = real_entry->e_authp ? real_entry->e_authp->ap_modification :
  602.           AP_SIMPLE;
  603.       if (!manager(binddn))
  604. !         effdn = (authtype % 3) >= authp ? binddn : NULLDN;
  605.       else
  606.           effdn = binddn;
  607.   
  608. --- 206,212 ----
  609.       authp = real_entry->e_authp ? real_entry->e_authp->ap_modification :
  610.           AP_SIMPLE;
  611.       if (!manager(binddn))
  612. !         effdn = trust_dn( binddn, authtype, authp );
  613.       else
  614.           effdn = binddn;
  615.   
  616. *** quipu/ds_bind.c.orig    Thu Aug 27 22:34:16 1992
  617. --- quipu/ds_bind.c    Thu Oct  1 14:27:29 1992
  618. ***************
  619. *** 38,43 ****
  620. --- 38,48 ----
  621.   
  622.   #include "osisec-stub.h"
  623.   
  624. + #ifdef KERBEROS
  625. + char    *kerberos_name;
  626. + char    *kerberos_keyfile;
  627. + #endif
  628.   extern LLog * log_dsap;
  629.   extern DN    mydsadn;
  630.   struct oper_act    * oper_alloc();
  631. ***************
  632. *** 91,97 ****
  633. --- 96,134 ----
  634.   /* We don't support any bilaterally-defined authentication procedures.
  635.    * Hence, if we get EXTERNAL credentials in the bind, reject them.
  636.    */
  637. + /* NOT!  We do now, if KERBEROS is defined */
  638. + #ifdef KERBEROS
  639. +     if ( arg->dba_auth_type == DBA_AUTH_EXTERNAL ) {
  640. +         int i;
  641.   
  642. +         if ( arg->dba_external->encoding->offset
  643. +             != choice_UNIV_0_single__ASN1__type ) {
  644. +             DLOG(log_dsap, LLOG_EXCEPTIONS,
  645. +                 ("Unknown EXTERNAL credentials"));
  646. +             error->dbe_version = DBA_VERSION_V1988;
  647. +             error->dbe_type = DBE_TYPE_SERVICE;
  648. +             error->dbe_value = DSE_SV_UNAVAILABLE;
  649. +             return (DS_ERROR_CONNECT);
  650. +         }
  651. +         if ( (i = kerberos_bind( arg, result, error )) == DS_OK ) {
  652. + #ifndef NO_STATS
  653. +             (void) sprintf (buff,"Bind (%d) (kerberos)",cn->cn_ad);
  654. +             pslog (log_stat,LLOG_NOTICE,buff,(IFP)dn_print,
  655. +                 (caddr_t)arg->dba_dn);
  656. + #endif
  657. +             cn->cn_authen = DBA_AUTH_EXTERNAL;
  658. +         } else {
  659. + #ifndef NO_STATS
  660. +             (void) sprintf (buff,"Bind (%d) (kerberos) (rejected)",
  661. +                 cn->cn_ad);
  662. +             pslog (log_stat,LLOG_NOTICE,buff,(IFP)dn_print,
  663. +                 (caddr_t)arg->dba_dn);
  664. + #endif
  665. +         }
  666. +         return( i );
  667. +     }
  668. + #endif KERBEROS
  669.       if (arg->dba_auth_type == DBA_AUTH_EXTERNAL)
  670.       {
  671.       DLOG(log_dsap, LLOG_EXCEPTIONS, ("EXTERNAL found in credentials"));
  672. ***************
  673. *** 734,737 ****
  674. --- 771,910 ----
  675.       return TRUE;
  676.   }
  677.   
  678. + #ifdef KERBEROS
  679.   
  680. + static kerberos_bind( arg, result, error )
  681. + struct ds_bind_arg        *arg;
  682. + struct ds_bind_arg        *result;
  683. + struct ds_bind_error        *error;
  684. + {
  685. +     Entry                ent;
  686. +     Attr_Sequence            as;
  687. +     AV_Sequence            av;
  688. +     AttributeValue            nameav;
  689. +     struct type_UNIV_EXTERNAL    *e = arg->dba_external;
  690. +     PE                pe;
  691. +     int                err, anyhost = 0;
  692. +     struct kerberos_parms        *kp;
  693. +     char                instance[INST_SZ], name[MAX_K_NAME_SZ];
  694. +     AUTH_DAT            ad;
  695. +     extern AttributeType        at_kerberosname;
  696. +     pe = e->encoding->un.single__ASN1__type;
  697. +     /* decode the kerberos authentication parameters */
  698. +     if ( decode_kerberos_parms( pe, &kp ) == NOTOK ) {
  699. +         DLOG( log_dsap, LLOG_EXCEPTIONS,
  700. +             ("decode_kerberos_parms failed") );
  701. +         error->dbe_version = DBA_VERSION_V1988;
  702. +         error->dbe_type = DBE_TYPE_SERVICE;
  703. +         error->dbe_value = DSE_SV_UNAVAILABLE;
  704. +         return( DS_ERROR_CONNECT );
  705. +     }
  706. +     pe_free( pe );
  707. +     /* check it with kerberos */
  708. +     if ( kerberos_keyfile == NULL )
  709. +         kerberos_keyfile = "";
  710. +     strcpy( instance, "*" );
  711. +     if ( kerberos_name == NULL )
  712. +         kerberos_name = "x500dsa";
  713. +     if ( (err = krb_rd_req( &kp->kp_ktxt, kerberos_name, instance, anyhost,
  714. +         &ad, kerberos_keyfile )) != KSUCCESS ) {
  715. +         DLOG( log_dsap, LLOG_NOTICE, ("krb_rd_req failed (%s)",
  716. +             krb_err_txt[err]) );
  717. +         error->dbe_version = DBA_VERSION_V1988;
  718. +         error->dbe_type  = DBE_TYPE_SECURITY;
  719. +         error->dbe_value = DSE_SC_INVALIDCREDENTIALS;
  720. +         return( DS_ERROR_CONNECT );
  721. +     }
  722. +     sprintf( name, "%s%s%s@%s", ad.pname, *ad.pinst ? "." : "", ad.pinst,
  723. +         ad.prealm );
  724. +     /* 
  725. +      * make sure the DN and kerberos principal correspond
  726. +      */
  727. +     /* find the entry */
  728. +     if ( (ent = local_find_entry( kp->kp_dn, TRUE )) == NULLENTRY ) {
  729. +         DLOG( log_dsap, LLOG_NOTICE, ("cannot find entry") );
  730. +         error->dbe_version = DBA_VERSION_V1988;
  731. +         error->dbe_type = DBE_TYPE_SERVICE;
  732. +         error->dbe_value = DSE_SV_UNAVAILABLE;
  733. +         return( DS_ERROR_CONNECT );
  734. +     }
  735. +     /* see if it has a kerberosName attribute */
  736. +     if ( (as = as_find_type( ent->e_attributes, at_kerberosname))
  737. +         == NULLATTR ) {
  738. +         DLOG( log_dsap, LLOG_NOTICE, ("no krbnames") );
  739. +         error->dbe_version = DBA_VERSION_V1988;
  740. +         error->dbe_type = DBE_TYPE_SECURITY;
  741. +         error->dbe_value = DSE_SC_AUTHENTICATION;
  742. +         return( DS_ERROR_CONNECT );
  743. +     }
  744. +     if ( (nameav = str2AttrV( name, at_kerberosname->oa_syntax ))
  745. +         == NULLAttrV ) {
  746. +         DLOG( log_dsap, LLOG_NOTICE, ("bad krbname format") );
  747. +         error->dbe_version = DBA_VERSION_V1988;
  748. +         error->dbe_type  = DBE_TYPE_SECURITY;
  749. +         error->dbe_value = DSE_SC_INVALIDCREDENTIALS;
  750. +         return( DS_ERROR_CONNECT );
  751. +     }
  752. +     /* see if it has the right value */
  753. +     for ( av = as->attr_value; av != NULLAV; av = av->avseq_next ) {
  754. +         if ( AttrV_cmp( av, nameav ) == 0 )
  755. +             break;
  756. +     }
  757. +     (void) AttrV_free( nameav );
  758. +     if ( av == NULLAV ) {
  759. +         DLOG( log_dsap, LLOG_NOTICE, ("krbname not found (%s)", name) );
  760. +         error->dbe_version = DBA_VERSION_V1988;
  761. +         error->dbe_type  = DBE_TYPE_SECURITY;
  762. +         error->dbe_value = DSE_SC_INVALIDCREDENTIALS;
  763. +         return( DS_ERROR_CONNECT );
  764. +     }
  765. +     arg->dba_dn = kp->kp_dn;
  766. +     /* 
  767. +      * send back mutual authentication - checksum + 1  (should be
  768. +      * encrypted in the session key XXX)
  769. +      */
  770. +     kp->kp_dn = mydsadn;
  771. +     ad.checksum++;
  772. +     memcpy( (char *) &(kp->kp_nonce), (char *) &(ad.checksum),
  773. +         sizeof(ad.checksum) );
  774. +     kp->kp_ktxt.length = 0;
  775. +     if ( encode_kerberos_parms( &pe, kp ) == NOTOK ) {
  776. +         DLOG( log_dsap, LLOG_EXCEPTIONS,
  777. +             ("encode_kerberos_parms failed") );
  778. +         error->dbe_version = DBA_VERSION_V1988;
  779. +         error->dbe_type = DBE_TYPE_SERVICE;
  780. +         error->dbe_value = DSE_SV_UNAVAILABLE;
  781. +         return( DS_ERROR_CONNECT );
  782. +     }
  783. +     free( kp );
  784. +     result->dba_version = DBA_VERSION_V1988;
  785. +     result->dba_auth_type = DBA_AUTH_EXTERNAL;
  786. +     result->dba_external = (struct type_UNIV_EXTERNAL *) smalloc(
  787. +         sizeof(struct type_UNIV_EXTERNAL) );
  788. +     result->dba_external->encoding = (struct choice_UNIV_0 *) smalloc(
  789. +         sizeof(struct choice_UNIV_0) );
  790. +     result->dba_external->indirect__reference = AUTH_TYPE_KERBEROS_V4;
  791. +     result->dba_external->direct__reference = NULLOID;
  792. +     result->dba_external->data__value__descriptor =
  793. +         str2qb( "KRBv4 server credentials", 24, 1 );
  794. +     result->dba_external->encoding->offset =
  795. +         choice_UNIV_0_single__ASN1__type;
  796. +     result->dba_external->encoding->un.single__ASN1__type = pe;
  797. +     return( DS_OK );
  798. + }
  799. + #endif
  800. *** dsap/x500as/das.py.orig    Wed Jun 24 10:28:40 1992
  801. --- dsap/x500as/das.py    Fri Sep 25 10:08:42 1992
  802. ***************
  803. *** 188,194 ****
  804.   
  805.   Credentials [[P struct ds_bind_arg *]]
  806.       ::=
  807. !     CHOICE <E< parm->dba_auth_type == DBA_AUTH_STRONG ? 2 : 1 >>
  808.              <D< (*parm)->dba_auth_type >>
  809.       {
  810.       simple
  811. --- 188,195 ----
  812.   
  813.   Credentials [[P struct ds_bind_arg *]]
  814.       ::=
  815. !     CHOICE <E< parm->dba_auth_type == DBA_AUTH_STRONG ? 2
  816. !         : parm->dba_auth_type == DBA_AUTH_EXTERNAL ? 3 : 1 >>
  817.              <D< (*parm)->dba_auth_type >>
  818.       {
  819.       simple
  820. ***************
  821. *** 200,206 ****
  822.       strong
  823.           [1] StrongCredentials [[p *]],
  824.       externalProcedure 
  825. !         [2] EXTERNAL [[p dba_vtmp]]
  826.       }
  827.   
  828.   -- Pulled up
  829. --- 201,208 ----
  830.       strong
  831.           [1] StrongCredentials [[p *]],
  832.       externalProcedure 
  833. !         [2] EXTERNAL [[p parm->dba_external]]
  834. ! --            [[E encode_external_type]] [[D decode_external_type]]
  835.       }
  836.   
  837.   -- Pulled up
  838. *** quipu/checkacl.c.bak    Fri Sep 25 16:33:02 1992
  839. --- quipu/checkacl.c    Thu Oct  1 16:53:41 1992
  840. ***************
  841. *** 35,40 ****
  842. --- 35,41 ----
  843.   
  844.   extern int     selector_rank[];
  845.   extern LLog    *log_dsap;
  846. + extern DN    trust_dn();
  847.   
  848.   static common_prefix_len( a, b )
  849.   char    *a;
  850. ***************
  851. *** 228,235 ****
  852.   
  853.       /* check auth policy allow us to believe binddn */
  854.       if ( e->e_authp != NULLAUTHP ) {
  855. !         binddn = (authtype % 3) >= e->e_authp->ap_listandsearch ?
  856. !             binddn : NULLDN;
  857.       }
  858.   
  859.       /* for each type in the filter */
  860. --- 229,236 ----
  861.   
  862.       /* check auth policy allow us to believe binddn */
  863.       if ( e->e_authp != NULLAUTHP ) {
  864. !         binddn = trust_dn( binddn, authtype,
  865. !             e->e_authp->ap_listandsearch );
  866.       }
  867.   
  868.       /* for each type in the filter */
  869. ***************
  870. *** 471,478 ****
  871.   
  872.       /* check auth policy allow us to believe binddn */
  873.       if ( ancestor->e_authp != NULLAUTHP ) {
  874. !         binddn = authtype >= ancestor->e_authp->ap_listandsearch ?
  875. !             binddn : NULLDN;
  876.       }
  877.   
  878.       if ( (rc = (struct result_count *) avl_find( (Avlnode *)local->st_sacls,
  879. --- 472,479 ----
  880.   
  881.       /* check auth policy allow us to believe binddn */
  882.       if ( ancestor->e_authp != NULLAUTHP ) {
  883. !         binddn = trust_dn( binddn, authtype,
  884. !             ancestor->e_authp->ap_listandsearch );
  885.       }
  886.   
  887.       if ( (rc = (struct result_count *) avl_find( (Avlnode *)local->st_sacls,
  888.